home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 050 / pp.arc / PP.DOC < prev    next >
Encoding:
INI File  |  1985-04-07  |  6.8 KB  |  199 lines

  1. [74036,3110]
  2. PP.DOC         16-Mar-85 6915         88
  3.  
  4.     Keywords: PRETTYPRINTER PROGRAM REFORMATTER CPM-80 CPM-86 MS-DOS
  5.  
  6.                                                                 PAGE 1
  7.  
  8.  
  9.  
  10.                   PP - Pascal Prettyprinting Program
  11.  
  12.                             14 March 1985
  13.  
  14.                                - Jon Hueras and
  15.                                  Henry Ledgard
  16.                                - Rick L. Marcus
  17.  
  18.  
  19. What PP Does
  20. ------------
  21.  
  22.      PP takes as input a Pascal program or program fragment and
  23. reformats it according to a standard set of prettyprinting rules.  The
  24. prettyprinted program is given as output.  PP makes no attempt to
  25. detect or correct syntactic errors in your program.  However,
  26. syntactic errors may result in erroneous prettyprinting.
  27.  
  28.      PP differs from some other prettyprinting programs in that it
  29. does not reformat your program "right down to every last semicolon."
  30. Such a philosophy requires formatting everything in a rigid fashion
  31. which is bound to be displeasing, or else it must provide you with a
  32. voluminous set of "options." Furthermore, such a scheme must do full
  33. syntax analysis of the program which means that it must be completely
  34. written and compilable.  If you wish to prettyprint a program still
  35. under development, then you are out of luck.
  36.  
  37.      PP, on the other hand, implements a strategy which states that it
  38. is not necessary to impose more than a "minimum" set of restrictions,
  39. and the prettyprinter should yield to your discretion beyond this
  40. minimum.  PP preserves blank lines and extra spaces you insert in the
  41. program as input, besides adding blank lines and extra spaces
  42. according to the rules for prettyprinting given below.
  43.  
  44.  
  45. General prettyprinting rules:
  46.  
  47.      1.  All statements and declarations begin on separate lines.
  48.  
  49.      2.  No input line may be longer than 80 characters.  Any output
  50.          line longer than 80 characters is continued on a separate
  51.          line.
  52.  
  53.      3.  The keywords "BEGIN", "END", "REPEAT", and "RECORD" are
  54.          forced to stand on lines by themselves (or possibly followed
  55.          by supporting comments).  In addition, the "UNTIL" clause of
  56.          "REPEAT-UNTIL" statement is forced to start on a new line.
  57.  
  58.      4.  A blank line is forced before the keywords "PROGRAM",
  59.          "PROCEDURE", "FUNCTION", "LABEL", "CONST", "TYPE", and "VAR".
  60.  
  61.      5.  A space is forced before and after the symbols ":=" and "=".
  62.          Additionally, a space is forced after the symbol ":".  Note
  63.          that only "="s in declarations are formatted; "="s in
  64.          expressions are ignored.
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. PP - Pascal Prettyprinting Program                              PAGE 2
  75.  
  76.  
  77.  
  78.  
  79.      6.  Spaces and blank lines already in your program are preserved
  80.          by PP, which adds (but does not subtract) blank lines and
  81.          spaces.  You can improve the readability of your programs by
  82.          taking advantage of this feature.  However, this feature also
  83.          means that you may sometimes have to manually de-indent (in
  84.          your editor) after block structure changes.
  85.  
  86.  
  87.  
  88. Indentation rules:
  89.  
  90.      1.  The body of a declaration is indented from the "LABEL",
  91.          "CONST", "TYPE", or "VAR" keyword which heads it.
  92.  
  93.      2.  The bodies of "BEGIN-END", "REPEAT-UNTIL", "WHILE", "WITH",
  94.          and "CASE" statements, as well as "RECORD-END" structures and
  95.          "CASE" variants (to one level) are indented from keywords
  96.          which head them.
  97.  
  98.      3.  An "IF-THEN-ELSE" statement is indented as follows:
  99.  
  100.                IF <expression>
  101.                   THEN <statement>
  102.                   ELSE <statement>
  103.  
  104.  
  105.  
  106. When to Use PP
  107. --------------
  108.  
  109.      PP is especially useful to reformat a Pascal program or program
  110. fragment that you have typed without regard to formatting (such as
  111. entering every line left-justified to save time).  Because the program
  112. need not be syntactically correct, PP provides the fastest means of
  113. obtaining a more readable version of your program.
  114.  
  115.      PP is best used to prettyprint a Pascal program already on a file
  116. or punched on cards.  PP changes neither the cards nor the file used
  117. as input.  Prettyprinting a program line-by-line as it is entered at a
  118. terminal is considerably less useful.
  119.  
  120.  
  121. How to Use PP
  122. -------------
  123.  
  124.      Type "PP" at the system command level followed by the old and new
  125. file names.  If the new file already exists, it will be overwritten
  126. without warning.  If the wrong number of file names are given, PP will
  127. print a message reminding the user of the correct system call.
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139. PP - Pascal Prettyprinting Program                              PAGE 3
  140.  
  141.  
  142.  
  143. Examples
  144. --------
  145.  
  146.      1.  Reformat a program called "prog1.pas" under CP/M:
  147.  
  148.             PP prog1.pas prog1.new       ;  reformat a program
  149.             TYPE prog1.new               ;  check that it is correct
  150.             ERA prog1.pas                ;  delete the old version
  151.             REN prog1.pas=prog1.new      ;  rename the new version
  152.  
  153.      2.  Reformat the same program under MS-DOS:
  154.  
  155.             PP prog1.pas prog1.new
  156.             TYPE prog1.new
  157.             ERASE prog1.pas
  158.             RENAME prog1.new prog1.pas
  159.  
  160.      3.  Preview PP's output before writing to a file:
  161.  
  162.             PP prog.pas con:            ;  on CP/M
  163.             PP prog.pas con             ;  on MS-DOS
  164.  
  165.      4.  Remind oneself how to use PP:
  166.  
  167.             PP
  168.  
  169.  
  170. History
  171. -------
  172.  
  173.      PP prettyprints a Pascal program or program fragment given as
  174. input.  It was originally named PRETTYPRINT and was written in Pascal
  175. by Jon Hueras and Henry Ledgard, University Computing Center and
  176. Computer and Information Science Dept., University of Massachusetts at
  177. Amherst, in August, 1976.  (See "An Automatic Formatting Program for
  178. Pascal", by Jon Hueras and Henry Ledgard, Pascal Newsletter #6, page
  179. 70, November, 1976.)
  180.  
  181.      Small corrections were made to PRETTYPRINT by Charles Fischer,
  182. Dept.  of Computer Science, University of Wisconsin, Madison, in 1977.
  183. PRETTYPRINT was modified for CDC-6000 Pascal by Rick L.  Marcus,
  184. University Computer Center, University of Minnesota, in September,
  185. 1978, and was renamed PRETTY.  Marcus also wrote this documentation.
  186.  
  187.      Peter Grogono adapted PRETTYPRINT to CP/M, using Pascal/Z.  He
  188. also made several modifications and renamed it PP (date unknown).  In
  189. 1984 Willett Kempton adapted the Pascal/Z version to Turbo Pascal,
  190. which required only minor mods.  The Turbo version uses a portable
  191. argument library "ARGLIB.PAS" to get file names, which makes it easier
  192. to adapt PP to other Pascal systems.  The Turbo version has been
  193. tested under CP/M-80, CP/M-86, and MS-DOS.  Kempton also adapted this
  194. documentation, from the CDC version, to apply to the microcomputer
  195. version.
  196.  
  197.  
  198.  
  199.